package com.obelisco.vista.controles;

import com.jgoodies.binding.adapter.echo.RadioButtonAdapter;
import com.jgoodies.binding.adapter.echo.TextComponentConnector;
import com.jgoodies.binding.beans.PropertyAdapter;
import com.jgoodies.binding.value.ValueModel;

import echopointng.RadioButtonEx;

public class BindingRadioButton extends RadioButtonEx {
	
	//ValueModel model = null;
	PropertyAdapter model = null;
	
	RadioButtonAdapter connector = null;

	public BindingRadioButton() {
		super();
		// TODO Auto-generated constructor stub
		initComponents();
	}
	
	private void initComponents() {
		setStyleName("Obelisco.RadioButton");
	}

	public BindingRadioButton(Object object, String property,Object valor) {
		super();
		if (model == null) {
			model = new PropertyAdapter(object, property, true);
		} else {
			model.setBean(object);
		}
		connector =  new RadioButtonAdapter(model, valor);
		setModel(connector);
	}

	public void setBinding(Object object, String property,Object valor) {
		if (model == null) {
			model = new PropertyAdapter(object, property, true);
		} else {
			model.setBean(object);
		}
		connector =  new RadioButtonAdapter(model, valor);
		setModel(connector);
	}

}
